{extend name="../public/header" /}
{block name="body"}
<body>
{include file="../public/top" uname="$roleInfo.uname" lv="$roleInfo.ulv" ls="$roleInfo.uyxb" jp="$roleInfo.uczb" /}
<div class="subject main">
    <div class="layui-row">
        <div class="content">
            <div class="current">
                <span class="position">{$roleInfo.map.mname}</span>
                <span class="state">{if $roleInfo.map.ispvp==0}[安全区]{else/}[PVP]{/if}</span>
                <span class="info ajax-goto" data-url="{:url('pets/index')}">返回</span>
            </div>
            <div class="refine">
                <div class="equip">
                    <input type="hidden" name="str" id="str" value="{$str}">
                    <div class="layui-col-md12" style="margin-bottom: 10px">
                        <div class="layui-card">
                            <div class="layui-card-header">
                                {$infoRolePets.cwname}
                                {if $roleInfo.cw == $infoRolePets.cwid}
                                <a class="layui-btn layui-btn-xs layui-btn-primary layui-border-green ajax-act" data-type="rest">休息</a>
                                {else /}
                                <a class="layui-btn layui-btn-xs layui-btn-primary layui-border-green ajax-act" data-type="gowar">出战</a>
                                {/if}
                            </div>
                            <div class="layui-card-body">
                                <p>Lv：{$infoRolePets.cwlv}</p>
                                <p>修为：{$infoRolePets.cwexp}</p>
                                <p>品质：{$infoRolePets.cwpz}</p>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md12" style="margin-bottom: 10px">
                        <div class="layui-card">
                            <div class="layui-card-header">属性</div>
                            <div class="layui-card-body">
                                <p>生命：{$infoRolePets.cwhp}/{$infoRolePets.cwmaxhp}</p>
                                <p>攻击：{$infoRolePets.cwgj}</p>
                                <p>防御：{$infoRolePets.cwfy}</p>
                                <p>暴击：{$infoRolePets.cwbj}</p>
                                <p>吸血：{$infoRolePets.cwxx}</p>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">附体</div>
                            <div class="layui-card-body">
                                <p>生命：{$infoRolePets.uphp}</p>
                                <p>攻击：{$infoRolePets.upgj}</p>
                                <p>防御：{$infoRolePets.upfy}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
{/block}
{block name="script"}
<script>
    layui.use(['jquery', 'form', 'layajax', 'upload', 'flow', 'element'], function () {
        var $ = layui.jquery
            , layajax = layui.layajax
            , upload = layui.upload
            , element = layui.element
            , flow = layui.flow
            , form = layui.form;

        $('.ajax-act').on('click', function () {
            var obj = $(this);
            var type = obj.data('type');
            var str = $('#str').val();

            var url = '{:url("petsAct")}';
            console.log('url', url);

            var map = {};
            map['type'] = type;
            map['str'] = str;

            $.post(url, map, function (res) {
                if (res.code == undefined) {
                    console.log('res为json字符串', res);
                    res = JSON.parse(res);
                } else {
                    console.log('res为json对象', res);
                }
                layer.msg(res.msg,{time:1000}, function(index){
                    location.reload();
                });
            });
        });

        form.render();
    });
</script>
{/block}